<template>
  <div class="boxf" v-show="isAlert">
    <div class="alert">
      <div
        :class="
          warndata[0] == 1 ? 'el-icon-warning color1' : 'el-icon-success color2'
        "
      >
        {{ warndata[0] == 1 ? "提示" : "成功" }}
      </div>
      <button @click="isAlert=false">X</button>
      <div class="content">{{ warndata[1] }}!</div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    warndata: {
      type: Array,
      require:true
    },
  },
  data() {
    return {
      isAlert: false,
    };
  },
  watch: {
    warndata(newVal) {
      this.isAlert = true;
      setTimeout(() => {
        this.isAlert = false;
      }, newVal[2]);
    },
  },
};
</script>

<style scoped>
.boxf {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.438);
}
.alert {
  position: fixed;
  z-index: 9999;
  top: 45%;
  width: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 10px;
  box-shadow: 0 0 10px #333;
  background: #fff;
  padding: 25px;
  font-size: 35px;
  text-align: left;
}
.alert button{
  font-size: 35px;
  font-weight: 500;
  position: absolute;
  top: 10px;
  right: 10px;
  background: none;
  padding: 5px 20px;
}
.color2 {
  color: #67c23a;
}
.color1 {
  color: #e6a23c;
}
.alert div {
  line-height: 1.5em;
}
.content {
  font-size: 1.3em;
  font-weight: 600;
  text-align: left;
}
</style>
